<!--
 * @页面名称:桌面快捷方式
 * @描述: 
 * @作者: 
 * @Date:
-->
<template>
  <div class="modules shortCut">
    <a-card>
      <template #title>
        <span>{{ itemConfig.MS_ModuleName }}</span>
        <router-link :to="{ path: itemConfig.MS_View }">
          <el-link type="primary">更多</el-link>
        </router-link>
      </template>
      <a-card-grid style="text-align: center" v-for="item in shortCutList" :key="item.SC_ID">
        <div style="display: flex; flex-direction: column; align-items: center" @click="routerTo(item)">
          <i
            :style="{ fontSize: item.size ? item.size : '18px', color: item.SC_ShortCutColor }"
            :color="item.SC_ShortCutColor"
            :class="item.SC_BackgroundIcon"
            class="iconfont2"
          >
          </i>
          <span style="margin-top: 8px">{{ item.SC_ShortCutName }}</span>
        </div>
      </a-card-grid>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { useAuthStore } from "@/stores/modules/auth";
import { useFondsStore } from "@/stores/modules/fonds";
import useCurrentInstance from "@/utils/useCurrentInstance";

const props = defineProps({
  itemConfig: {
    type: Object,
    default: () => {}
  }
});
// 路由
const router = useRouter();
const { proxy } = useCurrentInstance();
// pinia
const authStore = useAuthStore();
const fondsStore = useFondsStore();
// 快捷方式列表
const shortCutList = ref<any[]>([]);
// 获取快捷方式列表
const getShortCutList = () => {
  proxy.$vueAxios.get("MasterPermission/GetUserPermissionShortCut").then((res: any) => {
    shortCutList.value = res.List;
  });
};
// 路由跳转
const routerTo = async (item: any) => {
  console.log(item, authStore.newFlatMenuListGet);

  const obj = authStore.newFlatMenuListGet.filter((v: any) => v.MNU_ID === item.SC_RoutePath)[0];
  console.log("YYYYYYYYYYYYYYYYY", item);
  if (obj.Type === "FMT") {
    // 获取数据表
    const Res = await proxy.$vueAxios.post(
      "Master_Base_FormModel_Table/GetConditional",
      {
        order: "FMT_Type ASC",
        dtoList: [
          {
            fieldName: "FM_ID",
            fieldValue: obj.FM_ID
          }
        ]
      },
      { noLoading: true }
    );
    const childrenFmtId2 = Res.List.filter((v: any) => v.FMT_Parent_ID === obj.FMT_ID).map((v: any) => v.FMT_ID);
    fondsStore.SetFondsObj(obj);
    router.push({
      name: "MainModal",
      params: { id: obj.ID },
      query: {
        fmid: obj.FM_ID,
        fmtid: obj.FMT_ID,
        status: obj.Archive_Status,
        childrenFmtId: childrenFmtId2,
        fatherObj: undefined,
        fatherFmtId: undefined,
        fondsId: obj.Fonds_ID
      }
    });
  } else {
    router.push({ path: obj.path });
  }
};
onMounted(() => {
  console.log(props.itemConfig);

  getShortCutList();
});
</script>

<style scoped lang="scss">
:deep(.ant-card-body) {
  height: calc(100% - 60px);
  .ant-card-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
}
</style>
